"OSTree.RepoResolveRevExtFlags",
"OSTree.SePolicyRestoreconFlags",
"OSTree.StaticDeltaGenerateOpt",
- "OSTree.Sysroot",
"OSTree.SysrootSimpleWriteDeploymentFlags",
"OSTree.SysrootUpgrader",
"OSTree.SysrootUpgraderFlags",
"OSTree.KernelArgs",
"OSTree.RepoCheckoutAtOptions",
"OSTree.RepoCheckoutFilter",
+ "OSTree.SysrootWriteDeploymentsOpts",
]
ignore = [
pattern = "dummy_.+|ed25519_.+"
ignore = true
+[[object]]
+name = "OSTree.Sysroot"
+status = "generate"
+ [[object.function]]
+ name = "write_deployments_with_options"
+ [[object.function.parameter]]
+ name = "opts"
+ const = true
+
[[object]]
name = "OSTree.*"
status = "generate"
use DeploymentUnlockedState;
use Repo;
use SysrootSimpleWriteDeploymentFlags;
+#[cfg(any(feature = "v2017_4", feature = "dox"))]
+use SysrootWriteDeploymentsOpts;
glib_wrapper! {
pub struct Sysroot(Object<ostree_sys::OstreeSysroot, SysrootClass>);
}
}
- //#[cfg(any(feature = "v2017_4", feature = "dox"))]
- //pub fn write_deployments_with_options<P: IsA<gio::Cancellable>>(&self, new_deployments: &[Deployment], opts: /*Ignored*/&mut SysrootWriteDeploymentsOpts, cancellable: Option<&P>) -> Result<(), glib::Error> {
- // unsafe { TODO: call ostree_sys:ostree_sysroot_write_deployments_with_options() }
- //}
+ #[cfg(any(feature = "v2017_4", feature = "dox"))]
+ pub fn write_deployments_with_options<P: IsA<gio::Cancellable>>(&self, new_deployments: &[Deployment], opts: &SysrootWriteDeploymentsOpts, cancellable: Option<&P>) -> Result<(), glib::Error> {
+ unsafe {
+ let mut error = ptr::null_mut();
+ let _ = ostree_sys::ostree_sysroot_write_deployments_with_options(self.to_glib_none().0, new_deployments.to_glib_none().0, mut_override(opts.to_glib_none().0), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
+ if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
+ }
+ }
pub fn write_origin_file<P: IsA<gio::Cancellable>>(&self, deployment: &Deployment, new_origin: Option<&glib::KeyFile>, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
Generated by gir (https://github.com/gtk-rs/gir @ 2d1ffab1)
-from gir-files (https://github.com/gtk-rs/gir-files @ 203ae47)
+from gir-files (https://github.com/gtk-rs/gir-files @ ac0d3c9)
mod commit_sizes_entry;
#[cfg(any(feature = "v2020_1", feature = "dox"))]
pub use crate::commit_sizes_entry::*;
+#[cfg(any(feature = "v2017_4", feature = "dox"))]
+mod sysroot_write_deployments_opts;
+#[cfg(any(feature = "v2017_4", feature = "dox"))]
+pub use crate::sysroot_write_deployments_opts::*;
// tests
#[cfg(test)]
--- /dev/null
+use glib::translate::*;
+use ostree_sys::OstreeSysrootWriteDeploymentsOpts;
+
+pub struct SysrootWriteDeploymentsOpts {
+ pub do_postclean: bool,
+}
+
+impl Default for SysrootWriteDeploymentsOpts {
+ fn default() -> Self {
+ SysrootWriteDeploymentsOpts {
+ do_postclean: false,
+ }
+ }
+}
+
+impl<'a> ToGlibPtr<'a, *const OstreeSysrootWriteDeploymentsOpts> for SysrootWriteDeploymentsOpts {
+ type Storage = Box<OstreeSysrootWriteDeploymentsOpts>;
+
+ fn to_glib_none(&'a self) -> Stash<*const OstreeSysrootWriteDeploymentsOpts, Self> {
+ // Creating this struct from zeroed memory is fine since it's `repr(C)` and only contains
+ // primitive types.
+ // The struct needs to be boxed so the pointer we return remains valid even as the Stash is
+ // moved around.
+ let mut options =
+ Box::new(unsafe { std::mem::zeroed::<OstreeSysrootWriteDeploymentsOpts>() });
+ options.do_postclean = self.do_postclean.to_glib();
+ Stash(options.as_ref(), options)
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use glib_sys::{GFALSE, GTRUE};
+
+ #[test]
+ fn should_convert_default_options() {
+ let options = SysrootWriteDeploymentsOpts::default();
+ let stash = options.to_glib_none();
+ let ptr = stash.0;
+ unsafe {
+ assert_eq!((*ptr).do_postclean, GFALSE);
+ }
+ }
+
+ #[test]
+ fn should_convert_non_default_options() {
+ let options = SysrootWriteDeploymentsOpts { do_postclean: true };
+ let stash = options.to_glib_none();
+ let ptr = stash.0;
+ unsafe {
+ assert_eq!((*ptr).do_postclean, GTRUE);
+ }
+ }
+}
Generated by gir (https://github.com/gtk-rs/gir @ 2d1ffab1)
-from gir-files (https://github.com/gtk-rs/gir-files @ 203ae47)
+from gir-files (https://github.com/gtk-rs/gir-files @ ac0d3c9)